<?php

namespace Jlk3\Controller;

class DmjsonController extends CommonController {
	
	// 定码接口
	function dm(){
		// 周期
		if (I ( "zhouqi" ) == null) {
			$zhouqi = 3;
		} else {
			$zhouqi = I ( "zhouqi" );
		}
		// 定码
		if (I ( "disnum" ) == null) {
			$disnum = 4;
		} else {
			$disnum = I ( "disnum" );
		}
		//公式
		if (I ( "gongshi" ) == null) {
			$gongshi = 1;
		} else {
			$gongshi = I ( "gongshi" );
		}
		//位数
		if (I ( "weishu" ) == null) {
			$weishu = 1;//个位
		} else {
			$weishu = I ( "weishu" );
		}
		//只留前30期
		if(I("zqnum")==null){
			$zqnum = 30;
		}else{
			$zqnum = I("zqnum");
		}
			
		if(I("shama")==2){
			$shama = 2;
		}else{
			$shama = 1;
		}
		$this->dm_data($zhouqi,$disnum,$gongshi,$weishu,$zqnum,$shama);
	}
	
	
	//周期,定码,公式,位数1-5分别表示个十百千万
	function dm_data($zhouqi=2,$disnum=4,$gongshi=1,$weishu=1,$zqnum=30,$shama=1){
		//获取公式表名
		$gongshi_m = jlk3_num_to_gongshi($gongshi);
		//获取位数
		$weishu_arr = jlk3_num_to_weishu($weishu);
		// 获取当天的所有推荐
		$result_tjsj = jlk3_get_new_tj($gongshi_m);
		$result_arr = jlk3_get_dm_data($result_tjsj, $weishu_arr, $disnum, $zhouqi);
		//获取定码统计列表
// 		if($shama==2){
// 			$result_arr = jlk3_get_sm_data($result_tjsj, $weishu_arr, $disnum, $zhouqi);
// 		}else{
// 			$result_arr = jlk3_get_dm_data($result_tjsj, $weishu_arr, $disnum, $zhouqi);
// 		}
// 		//统计中挂
		$json_result = jlk3_get_tongji_result($result_arr, $zqnum, $disnum, $zhouqi, $gongshi, $weishu);
		
		echo json_encode($json_result,JSON_UNESCAPED_UNICODE);
	}
	
}